//
//  listVertices.c
//  TreeDecomposition
//
//  Created by Benoît Vanalderweireldt on 16/05/12.
//  Copyright (c) 2012 Sofware Project. All rights reserved.
//

#include <stdio.h>
#include "listVertices.h"
#include "vertice.h"

vertices addFirst(vertices liste, struct vertice v)
{
    linkVertices * newList = (linkVertices*)malloc(sizeof(linkVertices));
    newList->v = &v;
    if (liste->nxt!=NULL) {
        newList->nxt = liste;
    }
    else {
        newList->nxt = NULL;
    }
    liste = newList;
    return liste;
}

vertices addLast(vertices liste, struct vertice v)
{
    
    if(liste->v == NULL)
    {
        liste->v = &v;
        liste->nxt = NULL;
        return liste;
    }
    else
    {
        linkVertices* temp=liste;
        while(temp->nxt != NULL)
        {
            temp = temp->nxt;
        }
        linkVertices * newList = (linkVertices *)malloc(sizeof (linkVertices) );
        newList->v = &v;
        newList->nxt = NULL;
        temp->nxt = newList;
        return liste;
    }
}